package com.guoxin.chapter2.t1;

/**
 * @author guoxin
 * @date 2019/8/16
 */
public class HasSelfPrivateNum {

    public void addI(String username) {
        try {
            //私有变量，不会出现线程安全问题
            int num = 0;
            if ("a".equals(username)) {
                num = 100;
                System.out.println("a set over!");
                Thread.sleep(2000);
            } else {
                num = 200;
                System.out.println("b set over");
            }
            System.out.println(username + " num=" + num);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
